package com.example.kotlin.controller

import com.example.kotlin.pojo.`do`.UserDo
import com.example.kotlin.service.IUserService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RestController

@Api(tags = ["WebFlux Demo"])
@RestController
class HelloWorldController {

    @Autowired
    lateinit var userService: IUserService;


    @ApiOperation(value = "/")
    @GetMapping("/")
    fun hello(): String {
        return "hello kotlin"
    }

    @GetMapping("/path/{name}/{age}/{sex}")
    fun path(@PathVariable("name") name: String,
             @PathVariable("age") age: Int,
             @PathVariable("sex") sex: String): String {
        return "姓名：$name 年龄： $age 性别：$sex"
    }

    @GetMapping("/user/{id}")
    fun getById(@PathVariable("id") id: Long): UserDo {
        return userService.getById(id);
    }

}